import { createRouter, createWebHashHistory } from 'vue-router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      name: 'main',
      component: () => import('@/views/main.vue'),
      meta: { name: '布局容器' },
      redirect: { name: 'app-manager' },
      children: [
        {
          path: 'app-manager',
          name: 'app-manager',
          meta: { name: '应用管理' },
          component: () => import('@/views/pages/appManager/index.vue')
        }
      ]
    }
  ]
})

router.beforeEach(to => {
  NProgress.start()
  document.title = (to.meta.title || '应用设计') as string
  NProgress.done()
})

export default router